package com.edu.exam.enums;

/**
 * 监考分配详情状态枚举
 *
 * 定义监考分配详情的不同状态，用于跟踪监考员的分配和确认情况。
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-12
 */
public enum InvigilationAssignmentDetailStatus {
    PENDING("PENDING", "待分配"),
    ASSIGNED("ASSIGNED", "已分配"),
    CONFIRMED("CONFIRMED", "已确认"),
    REJECTED("REJECTED", "已拒绝"),
    COMPLETED("COMPLETED", "已完成"),
    ABSENT("ABSENT", "缺席");

    private final String code;
    private final String description;

    InvigilationAssignmentDetailStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 获取状态代码
     *
     * @return 状态代码
     */
    public String getCode() {
        return code;
    }

    /**
     * 获取状态描述
     *
     * @return 状态描述
     */
    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果代码无效
     */
    public static InvigilationAssignmentDetailStatus fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("Code cannot be null");
        }
        for (InvigilationAssignmentDetailStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }

    /**
     * 从描述创建枚举实例
     *
     * @param description 枚举描述
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果描述无效
     */
    public static InvigilationAssignmentDetailStatus fromDescription(String description) {
        if (description == null) {
            throw new IllegalArgumentException("Description cannot be null");
        }
        for (InvigilationAssignmentDetailStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}